package iot.wlink.network.devices.manager;

import iot.wlink.network.devices.bean.Identity;
import iot.wlink.network.payload.Payload;
import iot.wlink.network.payload.down.DownPayload;
import iot.wlink.network.payload.down.ServerErrorAck;

/**
 * @author : willian fu
 * @date : 2021/8/20
 * 统一的设备管理接口
 */
public interface DeviceManager {

    /**
     * 查询设备是否在线
     * @param uid uid
     * @return 是否在线
     */
    boolean isOnline(String uid);
    /**
     * 设备上线
     * @param uid uid
     */
    void deviceOnline(String uid);

    /**
     * 设备下线
     * @param uid uid
     */
    void deviceOffline(String uid);

    /**
     * 把设备踢下线
     * @param uid uid
     * @param error 错误应答信息
     */
    void kickOut(String uid, ServerErrorAck error);

    /**
     * 服务端主动断开连接
     * @param uid uid
     */
    void disconnect(String uid);

    /**
     * 获取设备远程外网IP
     * @param uid
     * @return
     */
    String getDeviceRemoteIp(String uid);

    /**
     * 发送数据到设备 长连接可用
     * @param payload 消息
     */
    void sendData(String uid, DownPayload payload);

    /**
     * 身份校验
     * @param identity 设备身份
     */
    void authentication(Identity identity);

    /**
     * 身份校验
     * @param token 设备身份令牌
     */
    void authentication(String token);

}
